<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>简单版本</title>
        <style>
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
            body {
                width: 100vw;
                min-height: 100vh;
                font-size: 2rem;
                display: flex;
                justify-content: center;
                align-items: center;
                background-color: #d6d6d6;
            }
            .container {
                position: relative;
                width: 60vw;
                height: 60vh;
                border-radius: 10px;
                overflow: hidden;
                box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.5);
            }
            .login,
            .register {
                position: absolute;
                width: 50%;
                height: 100%;
                top: 0;
                left: 0;
                background-color: #ffffff;
                transition: all 0.6s ease-in-out;
            }
            .under {
                width: 100%;
                height: 100%;
                /* background: url("https://picsum.photos/id/227/1000/1000") no-repeat center center/cover; */
                background-color: red;
                display: flex;
                justify-content: space-between;
                align-items: center;
            }
            .left,
            .right {
                width: 50%;
                height: 100%;
                display: flex;
                justify-content: center;
                align-items: center;
                transition: all 0.6s ease-in-out;
            }

            .login {
                z-index: 2;
            }
            .register {
                z-index: 1;
            }

            button {
                padding: 10px 20px;
                border: none;
                border-radius: 5px;
                background-color: #007aff;
                color: #ffffff;
                font-size: 1.5rem;
                cursor: pointer;
            }
            button:hover {
                background-color: #0057b7;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div class="login">登录</div>
            <div class="register">注册</div>
            <div class="under">
                <div class="left"><button onclick="handleClickToLogin()">去登录</button></div>
                <div class="right"><button onclick="handleClickToRegister()">去注册</button></div>
            </div>
        </div>

        <script>
            const loginCard = document.querySelector(".login");
            const registerCard = document.querySelector(".register");
            const left = document.querySelector(".left");
            const right = document.querySelector(".right");

            function handleClickToLogin() {
                loginCard.style.zIndex = 2;
                registerCard.style.zIndex = 1;
                loginCard.style.opacity = 1;
                registerCard.style.opacity = 0.5;
                loginCard.style.transform = "translateX(0%)";
                registerCard.style.transform = "translateX(0%)";

                // flip
                left.style.transform = "translateX(-20%)";
                left.style.opacity = 0.5;
                right.style.opacity = 1;
                right.style.transform = "translateX(0%)";
            }

            function handleClickToRegister() {
                loginCard.style.zIndex = 1;
                registerCard.style.zIndex = 2;
                loginCard.style.opacity = 0.5;
                registerCard.style.opacity = 1;
                loginCard.style.transform = "translateX(100%)";
                registerCard.style.transform = "translateX(100%)";

                left.style.transform = "translateX(0%)";
                left.style.opacity = 1;
                right.style.opacity = 0.5;
                right.style.transform = "translateX(20%)";
            }
        </script>
    </body>
</html>
